package tags.templates;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import main.PMF;
import main.UserView;

import DBClasses.NewsLetter;
import DBClasses.User;

public class UserName extends TagSupport
{
	@SuppressWarnings("unchecked")
	public int doStartTag() throws JspException
	{
		String result = "";
		PersistenceManager manager = PMF.get().getPersistenceManager();
		try
		{
			User usr = ((UserView) ((HttpServletRequest) pageContext
					.getRequest()).getSession().getAttribute("user")).getUser();
			result+=usr.getSName()+" "+usr.getSName();
		} catch (Exception ex)
		{
			result = "Вы не зарегистрированы О_О!";
		}
		try
		{
			pageContext.getOut().flush();
			pageContext.getOut().print(result);
		} catch (Exception ex)
		{
			throw new JspException(ex.getMessage());
		}
		manager.close();
		return SKIP_BODY;
	}

	public void release()
	{
	}
}
